import { commonParams } from '@/api/common-query.js'
import { service } from '@/api/service.js'
/**
 * jsonp 抓取歌手页数据
 * 接口：/search/hot
 */
export function getHotKey() {
  let data = Object.assign({}, commonParams, {
  })
  // 对象合并
  return service({
    method: 'GET',
    url: '/search/hot',
    params: data
  })
}

/**
 * 抓取搜索检索数据
 * 接口：/cloudsearch page: 第几页，perpage： 每页的数量
 */
export function search(query, page, perpage, zhida) {
  perpage = perpage > 0 ? parseInt(perpage) : 0
  page = page > 0 ? parseInt(page) : 0
  let pageNumber = 0
  let firstlimit = 0
  let endlimit = 0
  if (perpage > 0) {
    pageNumber = page > 0 ? page : 1
    firstlimit = (pageNumber - 1) * perpage
    endlimit = perpage
  } else {
    firstlimit = 0
    endlimit = 100000
  }
  let data = Object.assign({}, commonParams, {
    keywords: query,
    offset: firstlimit,
    limit: endlimit
  })
  // 对象合并
  return service({
    method: 'GET',
    url: '/search',
    params: data
  })
}
